# 28 区号匹配
import re

re_compile = re.compile(r'(\d{3}-)?\d{3}-\d{4}')
re_list = ['800-555-1212', '555-1212']
for i in re_list:
    m = re_compile.match(i)
    # print(m.group())


# 29支持圆括号或者连字符的区号
re_compile = re.compile(r'((\d{3}-)|(\(\d{3}\)))?\d{3}-\d{4}')
re_list = ['800-555-1212', '555-1212', '(800)555-1212']
for i in re_list:
    m = re_compile.match(i)
    print(m.group())